package cn.hx.mallBlog.service.impl;

import cn.hx.mallBlog.dao.CmsTopicCategoryDao;
import cn.hx.mallBlog.entity.CmsTopicCategory;
import cn.hx.mallBlog.service.CmsTopicCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 话题分类表(CmsTopicCategory)表服务实现类
 *
 * @author makejava
 * @since 2022-11-30 15:36:12
 */
@Service("cmsTopicCategoryService")
public class CmsTopicCategoryServiceImpl implements CmsTopicCategoryService {
    @Resource
    private CmsTopicCategoryDao cmsTopicCategoryDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CmsTopicCategory queryById(Long id) {
        return this.cmsTopicCategoryDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CmsTopicCategory> queryAllByLimit(int offset, int limit) {
        return this.cmsTopicCategoryDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param cmsTopicCategory 实例对象
     * @return 实例对象
     */
    @Override
    public CmsTopicCategory insert(CmsTopicCategory cmsTopicCategory) {
        this.cmsTopicCategoryDao.insert(cmsTopicCategory);
        return cmsTopicCategory;
    }

    /**
     * 修改数据
     *
     * @param cmsTopicCategory 实例对象
     * @return 实例对象
     */
    @Override
    public CmsTopicCategory update(CmsTopicCategory cmsTopicCategory) {
        this.cmsTopicCategoryDao.update(cmsTopicCategory);
        return this.queryById(cmsTopicCategory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.cmsTopicCategoryDao.deleteById(id) > 0;
    }

    @Override
    public List<CmsTopicCategory> queryAll(CmsTopicCategory cmsTopicCategory) {
        return cmsTopicCategoryDao.queryAll(cmsTopicCategory);
    }
}